﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.DTO;
using QLBH.DataModel;
using QLBH.Model.Controller;

namespace Module.Category.BL
{
    public class ProductCategoryManagementBL
    {
        private static ProductCategoryManagementBL instance;

        public static ProductCategoryManagementBL Instance
        {
            get 
            {
                if (instance==null)
                {
                    instance = new ProductCategoryManagementBL();
                }
                return instance; 
            }
            
        }
        public IList<NhomHangDTO> GetAllProductCategories()
        {
            try
            {
                IList<NhomHang> productCategories = ProductCategoryController.Instance.GetAll().ToList();
                return NhomHangAssembler.ToDTOs(productCategories).ToList();
            }
            catch (System.Exception ex)
            {
            	throw ex;
            }
            
        }
        
        public void UpdateProductCategory(NhomHangDTO editProductCategory)
        {
            try
            {
                NhomHang procate = NhomHangAssembler.ToEntity(editProductCategory);
                ProductCategoryController.Instance.Edit(procate);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        public void DeleteProductCategories(IList<NhomHangDTO> listProductCate)
        {
            try
            {
                IList<NhomHang> productCate = NhomHangAssembler.ToEntities(listProductCate).ToList();
                ProductCategoryController.Instance.Deletes(productCate);                
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }

    }
}
